Skip to content

fix: resolve escaped </script> in generated framework files#195

Open
angeloashmore wants to merge 1 commit into
mainfrom
aa/fix-escaped-script-tag
Open

fix: resolve escaped </script> in generated framework files#195
angeloashmore wants to merge 1 commit into
mainfrom
aa/fix-escaped-script-tag

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Jun 17, 2026

Copy link
Copy Markdown
Member

Resolves: #193

Description

prismic gen setup and prismic init generated Nuxt and SvelteKit files whose closing <script> tag was written as <\/script> (with a stray backslash), producing invalid SFC syntax.

The bundler escapes </script> to <\/script> in string literals, and our dedent wrapper reads the raw template strings, so the backslash leaked into the output. This points dedent at the resolved string segments instead, where the escape is already gone.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA

  1. In a Nuxt or SvelteKit project, delete the slice simulator file.
  2. Run prismic gen setup.
  3. Open the regenerated simulator file and confirm the closing tag is </script>.

🤖 Generated with Claude Code


Note

Low Risk
Localized change to the shared dedent helper plus a new test; behavior for non-</script> templates should match prior dedenting while fixing escape leakage.

Overview
Fixes invalid closing tags like <\/script> in files emitted by prismic gen setup and prismic init (Nuxt/SvelteKit simulator pages and similar).

dedent is no longer a thin re-export of dedent.withOptions. It now builds template output from resolved string segments and sets raw to those same segments so bundler escapes on literals (e.g. </script><\/script>) are not written into generated source.

Adds a gen setup integration test that treats the fixture as SvelteKit and asserts src/routes/slice-simulator/+page.svelte contains a literal </script> closing tag.

Reviewed by Cursor Bugbot for commit 6f16cfe. Bugbot is set up for automated code reviews on this repo. Configure here.

The bundler escapes `</script>` to `<\/script>` in string literals, and
dedent reads the raw template strings, so the backslash leaked into
generated Nuxt and SvelteKit files. Point dedent at the resolved string
segments instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gen setup emits invalid <\/script> (escaped slash) in Nuxt/SvelteKit generated files

1 participant